function f = gen_avg(data , frequency)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This function generates average given frequency
% Must start with first observation in a time frame, e.g. Q1 or m1
% If missing any one observation in the group then gives NaN
%   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if size(data , 2) > 1
    error('Must be column!')
end

f = sum(reshape(data , frequency , []))'/frequency;
end